package com.ecloud.service.translate.controller;

import javax.annotation.Resource;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ecloud.common.base.result.Result;
import com.ecloud.common.base.valid.ValidGroup.Insert;
import com.ecloud.common.base.valid.ValidGroup.QueryList;
import com.ecloud.common.base.valid.ValidGroup.Update;
import com.ecloud.openapi.translate.dto.BaseTranslateInfoDto;
import com.ecloud.service.translate.service.iface.IBaseTranslateInfoService;

/**
 * 翻译配置表 控制器
 *
 * @author LiuGangQiang Create in 2021/08/06
 */
@RestController
@RequestMapping({ "/base/translate/info" })
public class BaseTranslateInfoController {

    @Resource
    private IBaseTranslateInfoService baseTranslateInfoService;

    /**
     * 新增
     *
     * @author LiuGangQiang Create in 2021/08/09
     * @param dto 入参
     * @return {@link Result}
     */
    @PostMapping({ "/insert" })
    public Result<?> insert(@Validated({ Insert.class }) @RequestBody BaseTranslateInfoDto dto) {
        return baseTranslateInfoService.insert(dto);
    }

    /**
     * 删除数据
     *
     * @author LiuGangQiang Create in 2021/08/10
     * @param id 主键
     * @return {@link Result}
     */
    @DeleteMapping({ "/delete/{id}" })
    public Result<?> delete(@PathVariable("id") Long id) {
        return baseTranslateInfoService.delete(id);
    }

    /**
     * 修改数据
     *
     * @author LiuGangQiang Create in 2021/08/10
     * @param id  主键
     * @param dto 参数
     * @return {@link Result}
     */
    @PutMapping({ "/update/{id}" })
    public Result<?> update(@PathVariable("id") Long id, @Validated({ Update.class }) @RequestBody BaseTranslateInfoDto dto) {
        /* 设置参数 */
        dto.setId(id);
        return baseTranslateInfoService.update(dto);
    }

    /**
     * 查询列表
     *
     * @author LiuGangQiang Create in 2021/08/10
     * @param dto 入参
     * @return {@link Result}
     */
    @GetMapping({ "/list" })
    public Result<?> queryList(@Validated({ QueryList.class }) BaseTranslateInfoDto dto) {
        return baseTranslateInfoService.queryList(dto);
    }

    /**
     * 查询详情
     *
     * @author LiuGangQiang Create in 2021/08/10
     * @param id 主键
     * @return {@link Result}
     */
    @GetMapping({ "/detail/{id}" })
    public Result<?> queryDetail(@PathVariable("id") Long id) {
        return baseTranslateInfoService.queryDetail(id);
    }
}
